package cn.fighter3.controller;

import cn.fighter3.entity.node.*;
import cn.fighter3.result.Result;
import cn.fighter3.service.impl.BookService;
import cn.fighter3.service.impl.CnbookService;
import cn.fighter3.service.impl.PeopleService;
import cn.fighter3.service.node.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/book")
public class BookController {

    @Autowired
    BookService bookService;
    @Autowired
    PeopleService peopleService;
    @Autowired
    CnbookDao cnbookDao;
    @Autowired
    FgbookDao fgbookDao;
    @Autowired
    MscbookDao mscbookDao;
    @Autowired
    MulbookDao mulbookDao;
    @Autowired
    PapbookDao papbookDao;
    @Autowired
    PerbookDao perbookDao;
    @Autowired
    PeopleDao peopleDao;

    @Autowired
    CnbookService cnbookService;



//    @GetMapping("/mh")
//    public Result all11(){
//        List<Cnbook> cnbook=bookService.find1("*");
//        List<CustomNode> customNodes = new ArrayList<>();
//        for (Cnbook cnbook1:cnbook){
//            customNodes.add(new CustomNode(cnbook1.getTitle(),2,cnbook1,0));//cnbookDao.countcn(cnbook1.getBookId())
//        }
//        return (new Result(200,"hello",customNodes));
//    }


    //模糊查询不区分大小写
    @GetMapping("/mh/{name}")
    public Result findmh(@PathVariable("name") String name){
        List<Cnbook> cnbook=bookService.find1("*"+name+"*");
        List<Fgbook> fgbook=bookService.find2("*"+name+"*");
        List<Mscbook> mscbook=bookService.find3("*"+name+"*");
        List<Mulbook> mulbook=bookService.find4("*"+name+"*");
        List<Papbook> papbook=bookService.find5("*"+name+"*");
        List<Perbook> perbook=bookService.find6("*"+name+"*");
        List<People> people=peopleService.find7("*"+name+"*");
        //System.out.println(cnbook.getTitle());
        //System.out.println("!!!!!!!!!");
        //System.out.println(fgbook.getTitle());
        //System.out.println(people.getAuthorName());
        List<CustomNode> customNodes = new ArrayList<>();
        for (Cnbook cnbook1:cnbook){
            customNodes.add(new CustomNode(cnbook1.getTitle(),2,cnbook1,0));//cnbookDao.countcn(cnbook1.getBookId())
        }
        for (Fgbook fgbook1:fgbook){
            customNodes.add(new CustomNode(fgbook1.getTitle(),3,fgbook1,0));//fgbookDao.countfg(fgbook1.getBookId())
        }
        for (Mscbook mscbook1:mscbook){
            customNodes.add(new CustomNode(mscbook1.getTitle(),4,mscbook1,0));//mscbookDao.countmsc(mscbook1.getBookId())
        }
        for (Mulbook mulbook1:mulbook){
            customNodes.add(new CustomNode(mulbook1.getTitle(),5,mulbook1,0));//mulbookDao.countmul(mulbook1.getBookId())
        }
        for (Papbook papbook1:papbook){
            customNodes.add(new CustomNode(papbook1.getTitle(),6,papbook1,0));//papbookDao.countpap(papbook1.getBookId())
        }
        for (Perbook perbook1:perbook){
            customNodes.add(new CustomNode(perbook1.getTitle(),7,perbook1,0));//perbookDao.countper(perbook1.getBookId())
        }
        for (People people1:people){
            customNodes.add(new CustomNode(people1.getAuthorName(),1,people1,0));//peopleDao.countpeo(people1.getAuthorId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));

    }


    //精确查询
    @GetMapping("/jq/{name}")
    public Result findjq(@PathVariable("name") String name){
        List<Cnbook> cnbook=bookService.findByTitle1(name);
        List<Fgbook> fgbook=bookService.findByTitle2(name);
        List<Mscbook> mscbook=bookService.findByTitle3(name);
        List<Mulbook> mulbook=bookService.findByTitle4(name);
        List<Papbook> papbook=bookService.findByTitle5(name);
        List<Perbook> perbook=bookService.findByTitle6(name);
        List<People> people=peopleService.findByAuthorName(name);
        //System.out.println(cnbook.getTitle());
        //System.out.println("!!!!!!!!!");
        //System.out.println(fgbook.getTitle());
        //System.out.println(people.getAuthorName());
        List<CustomNode> customNodes = new ArrayList<>();
        for (Cnbook cnbook1:cnbook){
            customNodes.add(new CustomNode(cnbook1.getTitle(),2,cnbook1,0));//cnbookDao.countcn(cnbook1.getBookId())
        }
        for (Fgbook fgbook1:fgbook){
            customNodes.add(new CustomNode(fgbook1.getTitle(),3,fgbook1,0));//fgbookDao.countfg(fgbook1.getBookId())
        }
        for (Mscbook mscbook1:mscbook){
            customNodes.add(new CustomNode(mscbook1.getTitle(),4,mscbook1,0));//mscbookDao.countmsc(mscbook1.getBookId())
        }
        for (Mulbook mulbook1:mulbook){
            customNodes.add(new CustomNode(mulbook1.getTitle(),5,mulbook1,0));//mulbookDao.countmul(mulbook1.getBookId())
        }
        for (Papbook papbook1:papbook){
            customNodes.add(new CustomNode(papbook1.getTitle(),6,papbook1,0));//papbookDao.countpap(papbook1.getBookId())
        }
        for (Perbook perbook1:perbook){
            customNodes.add(new CustomNode(perbook1.getTitle(),7,perbook1,0));//perbookDao.countper(perbook1.getBookId())
        }
        for (People people1:people){
            customNodes.add(new CustomNode(people1.getAuthorName(),1,people1,0));//peopleDao.countpeo(people1.getAuthorId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }



    @GetMapping("/findAll")
    public Result findAll(){

        //return bookService.findAll();
        return (new Result(200,"hello",bookService.findAll()));
    }

    //cnbook  中文图书
    @GetMapping("/cnbook/find/{title}")
    public Result findByTitle1(@PathVariable("title") String title){
        System.out.println(title);
        List<Cnbook> cnbook=bookService.findByTitle1(title);
        List<CustomNode> customNodes=new ArrayList<>();
        for (Cnbook cnbook1:cnbook){
            customNodes.add(new CustomNode(title,2,cnbook1,0));//cnbookDao.countcn(cnbook1.getBookId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }
//    @GetMapping("/cnbook/find1/{name}")
////    public Cnbook findByName1(@PathVariable("name") String name){
////        System.out.println(name);
////        return bookService.findByName1(name);
////    }

    @GetMapping("/cnbook/findid/{id}")
    public Result findByBookId1(@PathVariable("id") String id){
        Cnbook cnbook=bookService.findByBookId1(id);
        CustomNode customNode=new CustomNode(cnbook.getTitle(),2,cnbook,0);//cnbookDao.countcn(cnbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
//         Optional<Cnbook> optionalCnbook = bookService.findByBookId(id);
//        if(optionalCnbook.isPresent()){
//            return optionalCnbook.get();
//        }
//        else{
//            return null;
//        }
    }
    @GetMapping("/cnbook/add/{id}/{title}/{publish}/{call}/{year}")
    public Result create1(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        Cnbook cnbook=bookService.create1(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(cnbook.getTitle(),2,cnbook,0);//cnbookDao.countcn(cnbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/cnbook/delete/{id}")
    public Result deleteById1(@PathVariable("id") String id){
        bookService.deleteById1(id);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/cnbook/deletetitle/{title}")
    public Result deleteByTitle1(@PathVariable("title") String title){
        bookService.deleteByTitle1(title);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/cnbook/update/{id}/{title}/{publish}/{call}/{year}")
    public Result updateByNode1(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        Cnbook cnbook=bookService.updateByNode1(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(cnbook.getTitle(),2,cnbook,0);//cnbookDao.countcn(cnbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }

    @GetMapping("/cnbook/all")
    public Result all1(){
        List<Cnbook> cnbookList = bookService.all1();
        List<CustomNode> customNodes = new ArrayList<>();
        for(Cnbook cnbook:cnbookList){
            customNodes.add(new CustomNode(cnbook.getTitle(), 2,cnbook,0));//cnbookDao.countcn(cnbook.getBookId())
        }
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/cnbook/count/{id}")
    public Result count1(@PathVariable("id") String id){
        return (new Result(200,"hello",bookService.count1(id)));
    }
//    //由书查找作者
//    @GetMapping("/cnbook/people/{title}")
//    public List<CustomNode> getAuthor1(@PathVariable("title") String title){
//        Cnbook cnbook=bookService.findByTitle1(title);
//        List<CustomNode> customNodes = new ArrayList<>();
//        Set<People> peopleSet=cnbook.getPeoplecn();
//        for (People people:peopleSet){
//            customNodes.add(new CustomNode(people.getAuthorName(),  1,people));
//        }
//        return customNodes;
//    }




    //fgbook 外文图书
    @GetMapping("/fgbook/find/{title}")
    public Result findByTitle2(@PathVariable("title") String title){
        System.out.println(title);
        List<Fgbook> fgbook=bookService.findByTitle2(title);
        List<CustomNode> customNodes=new ArrayList<>();
        for (Fgbook fgbook1:fgbook){
            customNodes.add(new CustomNode(title,3,fgbook1,0));//fgbookDao.countfg(fgbook1.getBookId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/fgbook/findid/{id}")
    public Result findByBookId2(@PathVariable("id") String id){
        //return bookService.findByBookId2(id);
        Fgbook fgbook=bookService.findByBookId2(id);
        CustomNode customNode=new CustomNode(fgbook.getTitle(),3,fgbook,0);//fgbookDao.countfg(fgbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
//         Optional<Cnbook> optionalCnbook = bookService.findByBookId(id);
//        if(optionalCnbook.isPresent()){
//            return optionalCnbook.get();
//        }
//        else{
//            return null;
//        }
    }
    @GetMapping("/fgbook/add/{id}/{title}/{publish}/{call}/{year}")
    public Result create2(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        Fgbook fgbook=bookService.create2(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(fgbook.getTitle(),3,fgbook,0);//fgbookDao.countfg(fgbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/fgbook/delete/{id}")
    public Result deleteById2(@PathVariable("id") String id){
        bookService.deleteById2(id);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/fgbook/deletetitle/{title}")
    public Result deleteByTitle2(@PathVariable("title") String title){
        bookService.deleteByTitle2(title);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/fgbook/update/{id}/{title}/{publish}/{call}/{year}")
    public Result updateByNode2(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        Fgbook fgbook=bookService.updateByNode2(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(fgbook.getTitle(),3,fgbook,0);//fgbookDao.countfg(fgbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/fgbook/all")
    public Result all2(){
        List<Fgbook> fgbookList = bookService.all2();
        List<CustomNode> customNodes = new ArrayList<>();
        for(Fgbook fgbook:fgbookList){
            customNodes.add(new CustomNode(fgbook.getTitle(), 3,fgbook,0));//fgbookDao.countfg(fgbook.getBookId())
        }
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/fgbook/count/{id}")
    public Result count2(@PathVariable("id") String id){
        return (new Result(200,"hello",bookService.count2(id)));
    }



    //mscbook  乐谱
    @GetMapping("/mscbook/find/{title}")
    public Result findByTitle3(@PathVariable("title") String title){
        System.out.println(title);
        List<Mscbook> mscbook=bookService.findByTitle3(title);
        List<CustomNode> customNodes=new ArrayList<>();
        for (Mscbook mscbook1:mscbook){
            customNodes.add(new CustomNode(title,4,mscbook1,0));//mscbookDao.countmsc(mscbook1.getBookId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/mscbook/findid/{id}")
    public Result findByBookId3(@PathVariable("id") String id){
        //return bookService.findByBookId3(id);
        Mscbook mscbook=bookService.findByBookId3(id);
        CustomNode customNode=new CustomNode(mscbook.getTitle(),4,mscbook,0);//mscbookDao.countmsc(mscbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
//         Optional<Cnbook> optionalCnbook = bookService.findByBookId(id);
//        if(optionalCnbook.isPresent()){
//            return optionalCnbook.get();
//        }
//        else{
//            return null;
//        }
    }
    @GetMapping("/mscbook/add/{id}/{title}/{publish}/{call}/{year}")
    public Result create3(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        //return bookService.create3(id, title, publish, call, year);
        Mscbook mscbook=bookService.create3(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(mscbook.getTitle(),4,mscbook,0);//mscbookDao.countmsc(mscbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/mscbook/delete/{id}")
    public Result deleteById3(@PathVariable("id") String id){
        bookService.deleteById3(id);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/mscbook/deletetitle/{title}")
    public Result deleteByTitle3(@PathVariable("title") String title){
        bookService.deleteByTitle3(title);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/mscbook/update/{id}/{title}/{publish}/{call}/{year}")
    public Result updateByNode3(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        //return bookService.updateByNode3(id, title, publish, call, year);
        Mscbook mscbook=bookService.updateByNode3(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(mscbook.getTitle(),4,mscbook,0);//mscbookDao.countmsc(mscbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/mscbook/all")
    public Result all3(){
        List<Mscbook> mscbookList = bookService.all3();
        List<CustomNode> customNodes = new ArrayList<>();
        for(Mscbook mscbook:mscbookList){
            customNodes.add(new CustomNode(mscbook.getTitle(), 4,mscbook,0));//mscbookDao.countmsc(mscbook.getBookId())
        }
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/mscbook/count/{id}")
    public Result count3(@PathVariable("id") String id){
        return (new Result(200,"hello",bookService.count3(id)));
    }



    //mulbook 多媒体资料
    @GetMapping("/mulbook/find/{title}")
    public Result findByTitle4(@PathVariable("title") String title){
        System.out.println(title);
        List<Mulbook> mulbook=bookService.findByTitle4(title);
        List<CustomNode> customNodes=new ArrayList<>();
        for (Mulbook mulbook1:mulbook){
            customNodes.add(new CustomNode(title,5,mulbook1,0));//mulbookDao.countmul(mulbook1.getBookId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/mulbook/findid/{id}")
    public Result findByBookId4(@PathVariable("id") String id){
        //return bookService.findByBookId4(id);
        Mulbook mulbook=bookService.findByBookId4(id);
        CustomNode customNode=new CustomNode(mulbook.getTitle(),5,mulbook,0);//mulbookDao.countmul(mulbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
//         Optional<Cnbook> optionalCnbook = bookService.findByBookId(id);
//        if(optionalCnbook.isPresent()){
//            return optionalCnbook.get();
//        }
//        else{
//            return null;
//        }
    }
    @GetMapping("/mulbook/add/{id}/{title}/{publish}/{call}/{year}")
    public Result create4(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        //return bookService.create4(id, title, publish, call, year);
        Mulbook mulbook=bookService.create4(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(mulbook.getTitle(),5,mulbook,0);//mulbookDao.countmul(mulbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/mulbook/delete/{id}")
    public Result deleteById4(@PathVariable("id") String id){
        bookService.deleteById4(id);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/mulbook/deletetitle/{title}")
    public Result deleteByTitle4(@PathVariable("title") String title){
        bookService.deleteByTitle4(title);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/mulbook/update/{id}/{title}/{publish}/{call}/{year}")
    public Result updateByNode4(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year) {
        //return bookService.updateByNode4(id, title, publish, call, year);
        Mulbook mulbook=bookService.updateByNode4(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(mulbook.getTitle(),5,mulbook,0);//mulbookDao.countmul(mulbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/mulbook/all")
    public Result all4(){
        List<Mulbook> mulbookList = bookService.all4();
        List<CustomNode> customNodes = new ArrayList<>();
        for(Mulbook mulbook:mulbookList){
            customNodes.add(new CustomNode(mulbook.getTitle(), 5,mulbook,0));//mulbookDao.countmul(mulbook.getBookId())
        }
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/mulbook/count/{id}")
    public Result count4(@PathVariable("id") String id){
        return (new Result(200,"hello",bookService.count4(id)));
    }






    //papbook  学位论文
    @GetMapping("/papbook/find/{title}")
    public Result findByTitle5(@PathVariable("title") String title){
        System.out.println(title);
        List<Papbook> papbook=bookService.findByTitle5(title);
        List<CustomNode> customNodes=new ArrayList<>();
        for (Papbook papbook1:papbook){
            customNodes.add(new CustomNode(title,6,papbook1,0));//papbookDao.countpap(papbook1.getBookId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/papbook/findid/{id}")
    public Result findByBookId5(@PathVariable("id") String id){
        //return bookService.findByBookId5(id);
        Papbook papbook=bookService.findByBookId5(id);
        CustomNode customNode=new CustomNode(papbook.getTitle(),6,papbook,0);//papbookDao.countpap(papbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
//         Optional<Cnbook> optionalCnbook = bookService.findByBookId(id);
//        if(optionalCnbook.isPresent()){
//            return optionalCnbook.get();
//        }
//        else{
//            return null;
//        }
    }
    @GetMapping("/papbook/add/{id}/{title}/{publish}/{call}/{year}")
    public Result create5(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        //return bookService.create5(id, title, publish, call, year);
        Papbook papbook=bookService.create5(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(papbook.getTitle(),6,papbook,0);//papbookDao.countpap(papbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/papbook/delete/{id}")
    public Result deleteById5(@PathVariable("id") String id){
        bookService.deleteById5(id);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/papbook/deletetitle/{title}")
    public Result deleteByTitle5(@PathVariable("title") String title){
        bookService.deleteByTitle5(title);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/papbook/update/{id}/{title}/{publish}/{call}/{year}")
    public Result updateByNode5(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year) {
        //return bookService.updateByNode5(id, title, publish, call, year);
        Papbook papbook=bookService.updateByNode5(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(papbook.getTitle(),6,papbook,0);//papbookDao.countpap(papbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/papbook/all")
    public Result all5(){
        List<Papbook> papbookList = bookService.all5();
        List<CustomNode> customNodes = new ArrayList<>();
        for(Papbook papbook:papbookList){
            customNodes.add(new CustomNode(papbook.getTitle(), 6,papbook,0));//papbookDao.countpap(papbook.getBookId())
        }
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/papbook/count/{id}")
    public Result count5(@PathVariable("id") String id){
        return (new Result(200,"hello",bookService.count5(id)));
    }





    //perbook  期刊
    @GetMapping("/perbook/find/{title}")
    public Result findByTitle6(@PathVariable("title") String title){
        System.out.println(title);
        List<Perbook> perbook=bookService.findByTitle6(title);
        List<CustomNode> customNodes=new ArrayList<>();
        for (Perbook perbook1:perbook){
            customNodes.add(new CustomNode(title,7,perbook1,0));//perbookDao.countper(perbook1.getBookId())
        }
        //return customNodes;
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/perbook/findid/{id}")
    public Result findByBookId6(@PathVariable("id") String id){
        //return bookService.findByBookId6(id);
        Perbook perbook=bookService.findByBookId6(id);
        CustomNode customNode=new CustomNode(perbook.getTitle(),7,perbook,0);//perbookDao.countper(perbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
//         Optional<Cnbook> optionalCnbook = bookService.findByBookId(id);
//        if(optionalCnbook.isPresent()){
//            return optionalCnbook.get();
//        }
//        else{
//            return null;
//        }
    }
    @GetMapping("/perbook/add/{id}/{title}/{publish}/{call}/{year}")
    public Result create6(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year){
        //return bookService.create6(id, title, publish, call, year);
        Perbook perbook=bookService.create6(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(perbook.getTitle(),7,perbook,0);//perbookDao.countper(perbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/perbook/delete/{id}")
    public Result deleteById6(@PathVariable("id") String id){
        bookService.deleteById6(id);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/perbook/deletetitle/{title}")
    public Result deleteByTitle6(@PathVariable("title") String title){
        bookService.deleteByTitle6(title);
        return new Result(200,"删除成功",null);
    }
    @GetMapping("/perbook/update/{id}/{title}/{publish}/{call}/{year}")
    public Result updateByNode6(@PathVariable("id") String id,@PathVariable("title") String title,@PathVariable("publish") String publish,@PathVariable("call") String call,@PathVariable("year") String year) {
        //return bookService.updateByNode6(id, title, publish, call, year);
        Perbook perbook=bookService.updateByNode6(id, title, publish, call, year);
        CustomNode customNode=new CustomNode(perbook.getTitle(),7,perbook,0);//perbookDao.countper(perbook.getBookId())
        //return customNode;
        return (new Result(200,"hello",customNode));
    }
    @GetMapping("/perbook/all")
    public Result all6(){
        List<Perbook> perbookList = bookService.all6();
        List<CustomNode> customNodes = new ArrayList<>();
        for(Perbook perbook:perbookList){
            customNodes.add(new CustomNode(perbook.getTitle(), 7,perbook,0));//perbookDao.countper(perbook.getBookId())
        }
        return (new Result(200,"hello",customNodes));
    }
    @GetMapping("/perbook/count/{id}")
    public Result count6(@PathVariable("id") String id){
        return (new Result(200,"hello",bookService.count6(id)));
    }




}
